﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using GzipManagerPro.UI.Utility;

namespace GzipManagerPro.UI.Controls.Preview
{
    public partial class PicturePreview : PreviewBase
    {
        public PicturePreview()
        {
            InitializeComponent();
        }

        public override void GeneratePreview(string path)
        {
            base.GeneratePreview(path);
            try
            {
                this.PictureBox.Image = Image.FromFile(path);
            }
            catch (Exception ex)
            {
                ex.MessageBox();
            }
        }

        public override Command[] GetCommands(CustomFileSystemInfo info)
        {
            List<Command> commands = new List<Command>();

            commands.AddRange(base.GetCommands(info));
            commands.Add(new CommandSeparator());

            commands.Add(new Command()
            {
                Title = string.Format("Open", info.Name),
                Image = ShellUtilities.GetFileIcon(info.FullName, true, true).ToBitmap(),
                Method = o =>
                {
                    System.Diagnostics.Process.Start(o.FullName);
                    return false;
                }
            });


            return commands.ToArray();
        }
    }
}
